﻿using System.Windows.Forms;
using SdmxMl.Panels;

namespace SdmxMl.Manager
{
    /// <summary>
    /// When saving artefact propose user different solutions if already exists
    /// </summary>
    public class AuthoriseRegistry
    {
        public static bool UnlockOnlySelected
        {
            get;
            set;
        }

        public static bool BackupRequired
        {
            get;
            set;
        }

        public static bool RequestCredential(IWin32Window owner, bool canUndoCheckout)
        {
            bool ret = false;
            UnlockOnlySelected = false;
            BackupRequired = false;

            if (canUndoCheckout)
            {
                // MUX
                DlgSaveUnlockBackup aDlg = new DlgSaveUnlockBackup(false, true);
                aDlg.ShowDialog(owner);
                UnlockOnlySelected = aDlg.DialogResult == DialogResult.No;
                BackupRequired = aDlg.DialogResult == DialogResult.OK;
                ret = aDlg.DialogResult != DialogResult.Cancel;
            }
            else
                ret = true;

            return ret;
        }
    }
}
